package com.atguigu.gmall.search.dao;

import com.atguigu.gmall.search.bean.Person;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
import java.util.Optional;

/**
 * 1、ElasticsearchRepository
 * 2、CrudRepository4
 * 3、PagingAndSortingRepository
 */
public interface PersonEsDao extends ElasticsearchRepository<Person,Long>{

    //findAllBy 全部查找 //SpringData 起名只要起好就行
    List<Person> findAllByAgeBetween(Integer age, Integer age2);
    //findAllByAgeBetweenOrNameEquals 年龄区间以及姓名
    List<Person> findAllByAgeBetweenOrNameEquals(Integer age, Integer age2, String name);
    //地址模糊查询
    List<Person> findAllByAddressLike(String address);
    //查找所有按模糊地址和年龄之间和 Id 大于等于多少
    List<Person> findAllByAddressLikeAndAgeBetweenAndIdGreaterThanEqual(String address, Integer age, Integer age2, Long id);
    //
    void deleteAllByAddressIsLike(String address);


    Optional<Person> findAllByIdEquals(Long aLong);
}